package cn.itcast.jdbc;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import cn.itcast.jdbc.domain.User;

public class ReflectTest {
	
	public static void main(String[] args) throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
		User user = (User) create(User.class);
		System.out.println(user);
	}
	
	static Object create(Class clazz) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
		Constructor con = clazz.getConstructor(String.class);
		Object obj = con.newInstance("test name");
		return obj;
	}

}


































